package com.qidian.service.impl;


import com.qidian.pojo.StudentBase;
import com.qidian.mapper.StudentBaseMapper;
import com.qidian.service.StudentBaseService;
import com.qidian.mapper.StudentBaseMapper;
import com.qidian.service.StudentBaseService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

/**
 * (StudentBase表)服务实现类
 *
 * @author 戴着假发的程序员
 * @since 2022-03-01 08:47:07
 */
@Service("studentBaseService")
public class StudentBaseServiceImpl implements StudentBaseService {
    @Resource
    private StudentBaseMapper studentBaseMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param studentId 主键
     * @return 实例对象
     */
    @Override
    public StudentBase selectById(Long studentId) {
        return this.studentBaseMapper.selectById(studentId);
    }

    /**
     * 分页查询
     *
     * @param page 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<StudentBase> selectPage(int page, int limit) {
        int start = (page-1)*limit;
        return this.studentBaseMapper.selectPage(start, limit);
    }
    /**
     * 分页查询
     *
     * @param page 查询起始位置
     * @param limit 查询条数
     * @param studentBase 实例对象
     * @return 对象列表
     */
    public List<StudentBase> selectPage(int page, int limit,StudentBase studentBase){
        int start = (page-1)*limit;
        return this.studentBaseMapper.selectPageByStudentBase(start, limit,studentBase);
    }
    /**
     * 查询所有
     *
     * @return 实例对象的集合
     */
     @Override
     public List<StudentBase> selectAll() {
        return this.studentBaseMapper.selectAll();
     }
     
    /**
     * 根据条件查询
     *
     * @return 实例对象的集合
     */
    @Override
    public List<StudentBase> selectList(StudentBase studentBase) {
        return this.studentBaseMapper.selectList(studentBase);
    }
    
    /**
     * 新增数据
     *
     * @param studentBase 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(StudentBase studentBase) {
        return this.studentBaseMapper.insert(studentBase);
    }

    /**
     * 批量新增
     *
     * @param studentBases 实例对象的集合
     * @return 生效的条数
     */
    @Override
    public int batchInsert(List<StudentBase> studentBases) {
        return this.studentBaseMapper.batchInsert(studentBases);
    }

    /**
     * 修改数据
     *
     * @param studentBase 实例对象
     * @return 实例对象
     */
    @Override
    public StudentBase update(StudentBase studentBase) {
        this.studentBaseMapper.update(studentBase);
        return this.selectById(studentBase.getStudentId());
    }

    /**
     * 通过主键删除数据
     *
     * @param studentId 主键
     * @return 是否成功
     */
    @Override
    public int deleteById(Long studentId) {
        return this.studentBaseMapper.deleteById(studentId);
    }

    /**
     * 通过主键删除数据
     *
     * @param studentId 主键
     * @return 是否成功
     */
    @Override
    public int deleteByIds(Long [] ids) {
        return this.studentBaseMapper.deleteByIds(ids);
    }
    
    /**
     * 查询总数据数
     *
     * @return 数据总数
     */
     @Override
     public int count(){
        return this.studentBaseMapper.count();
     }

     /**
     * 查询总数据数
     *
     * @return 数据总数
     */
    public int countByStudentBase(StudentBase studentBase){
        return this.studentBaseMapper.countByStudentBase(studentBase);
    }

                /**
     * 分页查询1
     *
     * @param page 查询起始位置
     * @param limit 查询条数
     * @param studentBase 实例对象
     * @return Map
     */
    public Map selectPageForLayui(int page, int limit,StudentBase studentBase){
        int start = (page-1)*limit;
        Map map = new HashMap();
        map.put("code",0);
        map.put("msg","");
        map.put("count",this.studentBaseMapper.countByStudentBase(studentBase));
        map.put("data",this.studentBaseMapper.selectPageByStudentBase(start, limit,studentBase));
        return map;
    };
}